package com.aitou.mrylive.presentation.ui.main.find.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.aitou.mrylive.R;
import com.aitou.mrylive.util.Const;
import com.aitou.mrylive.util.XImageLoader;

/**
 * Created by admin on 2016/9/26.
 */
public class ImageGridAdapter extends BaseAdapter {
    Context context;
    String[] list;

    public ImageGridAdapter(Context context, String[] list) {
        this.context = context;
        this.list = list;
    }


    @Override

    public int getCount() {
        return list == null ? 0 : list.length;
    }

    @Override
    public Object getItem(int position) {
        return list == null ? 0 : list[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder=null;
        if (convertView == null) {
            holder = new Holder();
            convertView = LayoutInflater.from(context).inflate(R.layout.item_photoselect_view, null);
            holder.img = (ImageView) convertView.findViewById(R.id.img);
            holder.isselect = convertView.findViewById(R.id.isselect);
            convertView.setTag(holder);
        }
        else {
            holder = (Holder) convertView.getTag();
        }
            holder.isselect.setVisibility(View.GONE);
            XImageLoader.load(Const.IMAG_NEW_URL + list[position]+".jpg", holder.img);

        return convertView;
    }




    class Holder{
        ImageView img;
        View isselect;
    }

    Runnable runnable=new Runnable() {
        @Override
        public void run() {

        }
    };
}
